/*
 * @Autor: dingxiaolin
 * @Date: 2021-06-02 13:12:44
 * @LastEditors: dingxiaolin
 * @LastEditTime: 2021-07-12 09:15:37
 */
import { ObjectDirective } from 'vue'
import { hasPermission } from '@/utils/permission/hasPermission'

export const permission: ObjectDirective = {
    mounted(el: HTMLButtonElement, binding, vnode) {
        const { value } = binding;
        if (value == undefined) return
        if (value.constructor === Array) {
            if (!hasPermission(value, true)) {
                el.remove()
            }
        } else {
            // console.log('b', value) //在tabel操作中使用自定义指令会有问题建议使用v-if
            if (!hasPermission(value, false)) {
                el.remove()
            }
        }

    }
}
